Test validity of path here. (shortcuts_insert_path): Don't check here.
authorMorten Welinder <terra@gnome.org>
Wed, 10 Mar 2004 17:55:16 +0000 (17:55 +0000)
committerMorten Welinder <mortenw@src.gnome.org>
Wed, 10 Mar 2004 17:55:16 +0000 (17:55 +0000)
2004-03-10  Morten Welinder  <terra@gnome.org>

* gtk/gtkfilechooserdefault.c
(gtk_file_chooser_default_add_shortcut_folder): Test validity of
path here.
(shortcuts_insert_path): Don't check here.
(get_file_info): Barf if name-only fails.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkfilechooserdefault.c

index 07150f39adef8d9f60a3f3f7ccb13536a87a935f..faac0f94a37073ede550ef232dec6f6b9fd116a3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2004-03-10  Morten Welinder  <terra@gnome.org>
 
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_add_shortcut_folder): Test validity of
+       path here.
+       (shortcuts_insert_path): Don't check here.
+       (get_file_info): Barf if name-only fails.
+
        * tests/testfilechooser.c (main): Add support for --multiple.
 
 Wed Mar 10 02:41:05 2004  Jonathan Blandford  <jrb@gnome.org>
index 07150f39adef8d9f60a3f3f7ccb13536a87a935f..faac0f94a37073ede550ef232dec6f6b9fd116a3 100644 (file)
@@ -1,5 +1,11 @@
 2004-03-10  Morten Welinder  <terra@gnome.org>
 
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_add_shortcut_folder): Test validity of
+       path here.
+       (shortcuts_insert_path): Don't check here.
+       (get_file_info): Barf if name-only fails.
+
        * tests/testfilechooser.c (main): Add support for --multiple.
 
 Wed Mar 10 02:41:05 2004  Jonathan Blandford  <jrb@gnome.org>
index 07150f39adef8d9f60a3f3f7ccb13536a87a935f..faac0f94a37073ede550ef232dec6f6b9fd116a3 100644 (file)
@@ -1,5 +1,11 @@
 2004-03-10  Morten Welinder  <terra@gnome.org>
 
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_add_shortcut_folder): Test validity of
+       path here.
+       (shortcuts_insert_path): Don't check here.
+       (get_file_info): Barf if name-only fails.
+
        * tests/testfilechooser.c (main): Add support for --multiple.
 
 Wed Mar 10 02:41:05 2004  Jonathan Blandford  <jrb@gnome.org>
index 07150f39adef8d9f60a3f3f7ccb13536a87a935f..faac0f94a37073ede550ef232dec6f6b9fd116a3 100644 (file)
@@ -1,5 +1,11 @@
 2004-03-10  Morten Welinder  <terra@gnome.org>
 
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_add_shortcut_folder): Test validity of
+       path here.
+       (shortcuts_insert_path): Don't check here.
+       (get_file_info): Barf if name-only fails.
+
        * tests/testfilechooser.c (main): Add support for --multiple.
 
 Wed Mar 10 02:41:05 2004  Jonathan Blandford  <jrb@gnome.org>
index 07150f39adef8d9f60a3f3f7ccb13536a87a935f..faac0f94a37073ede550ef232dec6f6b9fd116a3 100644 (file)
@@ -1,5 +1,11 @@
 2004-03-10  Morten Welinder  <terra@gnome.org>
 
+       * gtk/gtkfilechooserdefault.c
+       (gtk_file_chooser_default_add_shortcut_folder): Test validity of
+       path here.
+       (shortcuts_insert_path): Don't check here.
+       (get_file_info): Barf if name-only fails.
+
        * tests/testfilechooser.c (main): Add support for --multiple.
 
 Wed Mar 10 02:41:05 2004  Jonathan Blandford  <jrb@gnome.org>
index ab6645f7183d35b838e51fcc7899a716c8abe306..74a9feb8846938e6057adbf5ff0f1c775fedceb2 100644 (file)
@@ -822,8 +822,6 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean nam
   GtkFileFolder *parent_folder;
   GtkFileInfo *info;
 
-  info = NULL;
-
   if (!gtk_file_system_get_parent (file_system, path, &parent_path, error))
     return NULL;
 
@@ -836,11 +834,17 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean nam
                                              error);
   gtk_file_path_free (parent_path);
 
-  if (!parent_folder)
-    return NULL;
-
-  info = gtk_file_folder_get_info (parent_folder, path, error);
-  g_object_unref (parent_folder);
+  if (parent_folder)
+    {
+      info = gtk_file_folder_get_info (parent_folder, path, error);
+      g_object_unref (parent_folder);
+    }
+  else
+    {
+      info = NULL;
+      /* Name-only should not fail.  */
+      g_return_val_if_fail (!name_only, NULL);
+    }
 
   return info;
 }
@@ -872,17 +876,14 @@ shortcuts_insert_path (GtkFileChooserDefault *impl,
     }
   else
     {
-      /* Always check to make sure that the directory exists. */
-      GtkFileInfo *info = get_file_info (impl->file_system, path, FALSE, error);
-      if (info == NULL)
-       return FALSE;
-
       if (label)
        label_copy = g_strdup (label);
       else
-       label_copy = g_strdup (gtk_file_info_get_display_name (info));
-
-      gtk_file_info_free (info);
+       {
+         GtkFileInfo *info = get_file_info (impl->file_system, path, TRUE, error);
+         label_copy = g_strdup (gtk_file_info_get_display_name (info));
+         gtk_file_info_free (info);
+       }
 
       data = gtk_file_path_copy (path);
       pixbuf = gtk_file_system_render_icon (impl->file_system, path, GTK_WIDGET (impl),
@@ -3402,8 +3403,15 @@ gtk_file_chooser_default_add_shortcut_folder (GtkFileChooser    *chooser,
 {
   GtkFileChooserDefault *impl = GTK_FILE_CHOOSER_DEFAULT (chooser);
   gboolean result;
+  GtkFileInfo *info;
   int pos;
 
+  /* Test validity of path here.  */
+  info = get_file_info (impl->file_system, path, FALSE, error);
+  if (!info)
+    return FALSE;
+  gtk_file_info_free (info);
+
   pos = shortcuts_get_pos_for_shortcut_folder (impl, impl->num_shortcuts);
 
   result = shortcuts_insert_path (impl, pos, FALSE, NULL, path, NULL, FALSE, error);